<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
      layout:decorator="share/adminPop">

<div layout:fragment="content">
    <form id="data_save" class="form form-horizontal" enctype="multipart/form-data" action="/admin/videoPost/save" method="post">
        <input type="hidden" name="id" th:value="${m.id}" />
        <input type="hidden" name="videoId" th:value="${T(java.util.Base64).getEncoder().encodeToString(m.videoId)}" />
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>标题：</label>
            <div class="formControls col-6">
                <input type="text" class="input-text" th:value="${m.title}"  name="title">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3">分类：</label>
            <div class="formControls col-6">
                <select class="select select-box inline selCate" name="cateId" onchange="basicData.selCateChange(this)">
                    <option value="0" path="/0">--请选择</option>
                </select>
                <input type="hidden" id="cateName" name="cateName" th:value="${m.cateName}"/>
                <input type="hidden" id="catePath" name="catePath" th:value="${m.catePath}"/>
            </div>
        </div>
        <!--
        <div class="row cl">
            <label class="form-label col-3">发布状态：</label>
            <div class="formControls col-6">
                <select class="select select-box inline selState" name="state">
                    <option th:each="c:${states}" th:value="${c.id}" th:text="${c.name}"></option>
                </select>
            </div>
        </div>
        -->
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>内容：</label>
            <div class="formControls col-9">
                <textarea name="body" th:text="${m.body}" cols="" rows="" class="textarea valid" placeholder="" datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onkeyup="$.Huitextarealength(this,200)"></textarea>
            </div>
        </div>
         <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>缩略图：</label>
            <div class="formControls col-9">
                <input type="file" name="file"/>
                <div th:each="i:${#strings.listSplit(m.thumbnail,',')}" >
                    <span th:text="${i}"></span>
                    <a class="ml-5" style="text-decoration:none"  th:onclick="'javascript:delThumbnail('+${m.id}+',\''+${i}+'\')'"  title="删除"><i class="Hui-iconfont"></i></a>
                </div>
                <input type="hidden" th:value="${m.thumbnail}" name="thumbnail" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>下载地址：</label>
            <div class="formControls col-9">
                <input type="text" class="input-text" th:value="${m.downloadUrl}"  name="downloadUrl">
            </div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-2">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">&nbsp;&nbsp;&nbsp;&nbsp;
                <button onclick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>

        </div>

    </form>
</div>
<script type="text/javascript" layout:fragment="scripts" th:inline="javascript">
     $('#scrollTop').val(parent.$('.dataTables_scrollBody').scrollTop());//保持滚动条

    basicData.getCateTree(".selCate", '[[${m.cateId}]]');

    function delThumbnail(id, file) {
        if (!confirm('确定删除吗？')) return;

        $lv.actionJson('/admin/videoPost/del/'+id+'/'+file, function (r) {
            if (r && r.code == 1) tb.fnDraw(true);
            else $lv.toast('删除失败！');
        });
    }
    // $('.btn-primary').click(function () {
    //
    //    $lv.actionJson('/admin/videoPost/save', function (r) {
    //        if (r.code) {
    //            $lv.toast('成功！');
    //            //alert(parent.tb);
    //            parent.tb.fnDraw();
    //            layer_close();
    //
    //        } else $lv.toast('no');
    //    }, 'data_save');
    // });
</script>